// 建筑系统类型定义

import type { ResourceCost, ResourceProduction } from './resources'
import type { UnlockCondition, Effect } from './game'

export interface Building {
  id: string
  name: string
  description: string
  category: BuildingCategory
  level: number
  maxLevel: number
  costs: ResourceCost[]
  buildTime: number
  maintenance: ResourceCost[]
  effects: BuildingEffect[]
  unlockConditions: UnlockCondition[]
  planetId?: string
  isActive: boolean
  icon: string
}

export type BuildingCategory = 'infrastructure' | 'industrial' | 'research' | 'military' | 'special'

export interface BuildingEffect extends Effect {
  buildingId: string
  level: number
}

export interface BuildingUpgrade {
  fromLevel: number
  toLevel: number
  costs: ResourceCost[]
  buildTime: number
  newEffects: BuildingEffect[]
}

export interface BuildingTemplate {
  id: string
  name: string
  description: string
  category: BuildingCategory
  baseStats: BuildingStats
  upgrades: BuildingUpgrade[]
  unlockConditions: UnlockCondition[]
  icon: string
  maxLevel: number
}

export interface BuildingStats {
  production: ResourceProduction[]
  consumption: ResourceCost[]
  capacity: Record<string, number>
  efficiency: number
  powerConsumption: number
  workerCapacity: number
}

export interface PlanetaryBonus {
  buildingId: string
  planetType: string
  bonusType: 'production' | 'efficiency' | 'capacity' | 'cost_reduction'
  value: number
  modifier: 'add' | 'multiply'
}

// 建筑ID常量
export const INFRASTRUCTURE_BUILDINGS = {
  RESIDENTIAL_COMPLEX: 'residential_complex',
  HYDROPONIC_FARM: 'hydroponic_farm',
  POWER_PLANT: 'power_plant',
  WATER_RECYCLER: 'water_recycler',
  LIFE_SUPPORT: 'life_support'
} as const

export const INDUSTRIAL_BUILDINGS = {
  METAL_MINE: 'metal_mine',
  CRYSTAL_EXTRACTOR: 'crystal_extractor',
  GAS_COLLECTOR: 'gas_collector',
  REFINERY: 'refinery',
  FACTORY: 'factory',
  ELECTRONICS_LAB: 'electronics_lab',
  CHEMICAL_PLANT: 'chemical_plant'
} as const

export const RESEARCH_BUILDINGS = {
  RESEARCH_CENTER: 'research_center',
  OBSERVATORY: 'observatory',
  QUANTUM_LAB: 'quantum_lab',
  BIOLAB: 'biolab'
} as const

export const MILITARY_BUILDINGS = {
  SHIPYARD: 'shipyard',
  DEFENSE_GRID: 'defense_grid',
  MILITARY_ACADEMY: 'military_academy',
  WEAPONS_FACTORY: 'weapons_factory'
} as const

export const SPECIAL_BUILDINGS = {
  ANTIMATTER_LAB: 'antimatter_lab',
  COMMUNICATION_HUB: 'communication_hub',
  WORMHOLE_GENERATOR: 'wormhole_generator',
  DYSON_SPHERE_COMPONENT: 'dyson_sphere_component'
} as const